package com.cd2cd.controller;

import com.cd2cd.service.SysDictService;
import com.cd2cd.vo.*;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@RequestMapping("sysDict")
public class SysDictController extends BaseController  {

    @Resource
    private SysDictService sysDictService;

    @RequestMapping( value = "list", method = RequestMethod.GET)
    @ResponseBody
    public BaseRes<DataPageWrapper<SysDictVo>> queryPageList( Integer currPage, Integer pageSize, SysDictVo sysDictVo) {

        return sysDictService.list(currPage, pageSize, sysDictVo);
    }

    @RequestMapping( value = "detail/{id}", method = RequestMethod.GET)
    @ResponseBody
    public BaseRes<SysDictVo> detail(@PathVariable("id") Integer id) {
        return sysDictService.detail(id);
    }

    @RequestMapping( value = "del/{id}", method = RequestMethod.DELETE)
    @ResponseBody
    public BaseRes<String> del(@PathVariable("id") Integer id) {

        return sysDictService.del(id);
    }

    @RequestMapping(value = "add", method = RequestMethod.POST)
    @ResponseBody
    public  BaseRes<String> add(@Validated @RequestBody SysDictVo sysDictVo, BindingResult bindingResult) {

        return sysDictService.add(sysDictVo);
    }

    @RequestMapping(value = "modify", method = RequestMethod.POST)
    @ResponseBody
    public BaseRes<String> modify(@Validated @RequestBody SysDictVo sysDictVo, BindingResult bindingResult) {

        return sysDictService.modify(sysDictVo);
    }
}
